package cn.dlc.com.base;

/**
 * @author 邓立川
 * @date 2021/3/12 21:07
 * @desc 最坏情况
 */
public class Demo5 {

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,56};
        int num = 56;
        int index = search(num, arr);
        System.out.println(index);
    }

    private static int search(int num, int[] arr){
        for (int i = 0; i<arr.length ; i++) {
            if(arr[i] == num) {
                return i;
            }
        }
        return -1;
    }
}
